import tkinter as tk

from Attriabte import Color, DTO
from View.WindowComponent.BodyFrame.BodyFrame import BodyFrame
from View.WindowComponent.BodyFrame.Remember import RememberWord
from View.WindowComponent.BodyFrame.SelectWord import SelectWord
from View.WindowComponent.ColorHoverLabel import ColorHoverLabel


class ModeSelectFrame(BodyFrame):
    """
    模式选择界面
    """

    def set_block(self, frame, title, image=None, info=None, click_call_back=None, fg=Color.light_white):
        bg = frame['bg']
        tk.Label(frame, text=title, font=("黑体", 22), bg=bg, fg=fg).pack(pady=12)
        tk.Label(frame, image=image, bg=bg).pack(pady=12) if image else ...
        colorHoverLabel = ColorHoverLabel(
            frame,
            DTO.ColorHoverWidgetDto(
                text="Link Start",
                bg=bg,
                fg=fg,
                hover_fg='red',
                hover_bg=bg,
                font=("consolas", 30)
            ),
            click=click_call_back
        )

        tk.Label(
            frame,
            font=("黑体"),
            text=info,
            bg=bg,
            fg=fg,
            wraplength=160,
            justify='left'
        ).pack(pady=12)
        colorHoverLabel.get().pack(pady=12)

    def pack(self):
        hei, wid = .7, .3
        self.hei, self.wid = hei, wid
        self.FrameAll = tk.Frame(self.frame, bg=Color.duibi_yellow)
        self.set_block(
            self.FrameAll,
            "复习",
            self.layout.app.image_328,
            fg='black',
            info='复习所有词组',
            click_call_back=lambda: self.layout.body(
                frame=RememberWord(self.layout, None, self.ws).get(), must_do=True
            )
        )
        self.FrameAll.place(
            relx=(1 - wid * 2 - 0.1) / 2,
            rely=(1 - hei) / 2,
            relwidth=wid,
            relheight=hei,
        )

        self.FramePath = tk.Frame(self.frame, bg=Color.duibi_blue)
        self.set_block(
            self.FramePath,
            "指定单词组学习",
            self.layout.app.image_324,
            "对指定单词组的单项复习",
            click_call_back=lambda: self.layout.body(
                frame=SelectWord(self.layout, self.ws).get(), must_do=True
            )
        )

        # region 复习单词组

        # endregion

        # region 全部单词记忆

        # endregion

        self.FramePath.place(
            relx=(1 - wid * 2 - 0.1) / 2 + wid + 0.1,
            rely=(1 - hei) / 2,
            relwidth=wid,
            relheight=hei,
        )
        tk.Label(self.frame, text='')
